// 清单详情js
var $scope = null;
$(function() {
	var appElement = document.querySelector('[ng-controller=main]');
	$scope = angular.element(appElement).scope();
	var checkListId = locationHref("checkListId");
	$scope.checkListId=checkListId;
	  initialPage($scope);
	$scope.methods.checkList();
	$scope.methods.checkListRead();
	$scope.methods.queryResourceList();
	  
});
// 初始化值
function initialPage($scope) {
	
	
}
var mainApp = angular.module("mainApp", []);
mainApp.controller('main', function($scope) {
	$scope.search={};
	$scope.methods = {
		//清单详情列表第一部分
		checkList : function() {
			$.ajax({
			    url:$.shysUrlPrefix+'/website/checkList/'+$scope.checkListId,
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				beforeSend: function () {
				      $(".loading").show();
				  },
			    success:function (data) {
					if (data.data != null) {
						console.log(data.data)
					   $scope.checkListData = data.data;	//
					    $scope.dynamicFile=data.data.bridgeFiles?data.data.bridgeFiles.split(','):"";
					   $scope.$apply();
					} else {
					   
					}
					
			    },
				complete: function () {
				       $(".loading").hide();
				   },
			
			})
		},
		//第二部分
		checkListRead : function() {
			var params = '';
			params += '&pageNum=1'
			params += '&pageSize=6'
			if ($scope.checkListId) {
			    params += '&checkListId=' + $scope.checkListId
			}
			$.ajax({
			    url:$.shysUrlPrefix+'/website/checkListRead/queryReadList?'+params,
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				beforeSend: function () {
				      $(".loading").show();
				  },
			    success:function (data) {
					console.log(data)
					 $scope.checkListContent1 = data.rows.length;	
					if (data.rows != null && data.rows.length > 0) {
					   $scope.checkListContent = data.rows;	//	  
					   $scope.$apply();
					    
					} else {
					   
					}
					
			    },
				complete: function () {
				       $(".loading").hide();
				   },
			
			})
		},
		// 第三部分资源
		queryResourceList : function() {
			var params = '';
			params += '&pageNum=1'
			params += '&pageSize=20'
			if ($scope.checkListId) {
			    params += '&checkListId=' + $scope.checkListId
			}
			$.ajax({
			    url:$.shysUrlPrefix+'/website/checkListRead/queryResourceList?'+params,
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				beforeSend: function () {
				      $(".loading").show();
				  },
			    success:function (data) {
					console.log(data)
					 $scope.resourceList1 = data.rows.length;	
					if (data.rows != null && data.rows.length > 0) {
					   $scope.resourceList = data.rows;	//	
						 console.log($scope.resourceList)
					   $scope.$apply();
					    
					} else {
					   
					}
					
			    },
				complete: function () {
				       $(".loading").hide();
				   },
			
			})
		},
		// 更多阅读
		moreRead: function () {
		 console.log($scope.checkListId)
		 window.location.href="read.html?checkListId="+$scope.checkListId
		},
		newsMore: function () {
		 window.location.href="read.html"
		},
		detailM: function (dynamicId) {
		 console.log(dynamicId)
		 window.location.href="dongtai-detail.html?dynamicId="+dynamicId
		},
		// 跳转详情页
		labelDetailClick: function (label) {
		 console.log(label)
		 if(label.resourceType=='image'&&label.resourceId){
			  window.location.href="accRes-detail.html?imageId="+label.resourceId
		 }else if(label.resourceType=='video'&&label.resourceId){
			  window.location.href="video-detail.html?videoId="+label.resourceId
		 }else if(label.resourceType=='model'&&label.resourceId){
			  // window.location.href="model-detail.html?modelId="+label.modelId
			  $.ajax({
			  	url: $.shysUrlPrefix + '/website/model/' +label.resourceId,
			  	type: 'get',
			  	dataType: 'JSON',
			  	async: true, //同步方式发起请求
			  	success: function(data) {
			  		if (data.data != null ) {
			  			window.open(data.data.modelUrl);
			  			$scope.$apply();
			  		} else {
			  		
			  		}
			  		
			  	},
			  		
			  })
		 }
		
		},
		
	};
});











